<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加及修改用户个人信息</title>
    <link rel="stylesheet" href="css/bootstrap.css"/>
</head>
<body>
<div class="container">

    <h2 class="text-center">添加个人信息</h2>
    <br>

    <form  method="post"  name="form1" role="form"
          class="form-horizontal">
        <div class="form-group">
            <label class="col-md-2 control-label">昵称：</label>
            <div class="col-md-10">
                <input class="form-control" type="text" name="uname" id="uname" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label">电话号码：</label>
            <div class="col-md-10">
                <input class="form-control" type="text" name="phone" id="phone">
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label" >出生日期：</label>
            <div class="col-md-10">
                <input class="form-control" type="date" name="birth" id="birth">
            </div>
        </div>
        <!--<div class="form-group  text-center">
            <label class="col-md-2 control-label">新增收货地址：</label>
            <input type="button" class="btn btn-primary" id="add_address" >
        </div>-->
        <div class="form-group  text-center">
            <input type="button" class="btn btn-primary" value="保存个人信息" id="submit">
        </div>
    </form>
</div>
</div>


</body>
<script src="js/jquery-3.2.1.js"></script>
<script src="js/layer/layer.js"></script>
<script src="js/Vue-2.6.11.js"></script>
<script src="js/axios.min.js"></script>
<script src="js/global.js"></script>
<script>
    $(function () {
        queryById();

       $("#submit").click(function () {
           $.post('user/information_update', {
               uname: $('#uname').val(),
               phone: $('#phone').val(),
               birth: $('#birth').val()
           }, function (data) {
               console.log(data.msg);
           }, 'JSON');
       })
    })

     function queryById() {
         $.post('user/querybyId', function (data) {
             if(data.code==200){
                 $('#uname').val(data.data.uname)
                 $('#phone').val(data.data.phone)
                 $('#birth').val(data.data.birth)
             }else {
                 console.log(data.msg);
             }

         }, 'JSON');
    }
</script>
</html>